package com.example.myapplication;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class adapter_activity extends AppCompatActivity {
    RecyclerView recyclerView;
//    List list;
    Adapter adapter;
    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_adapter);

        recyclerView=findViewById(R.id.recyler);

//        list=new ArrayList<String>();
//
//        for(int i=0;i<10;i++){
//            list.add("这是第"+i+"条数据");
//        }

        List<Map<String,Object>> list=new ArrayList<>();

        String[] name={"123","456","789"};

        int[] phone={R.drawable.p1,R.drawable.p1,R.drawable.p1};

        String[] price={"iphone14","iphone15","iphone16"};

        String[] config={"5999","8999","9999"};

        for(int i=0;i<name.length;i++){
            Map<String,Object> map=new HashMap<>();
            map.put("name",phone[i]);
            map.put("price",price[i]);
            map.put("config",config[i]);
            list.add(map);
        }

        Context context=this;

        adapter=new Adapter(context,list);

        LinearLayoutManager manager=new LinearLayoutManager(this);

        manager.setOrientation(RecyclerView.VERTICAL);

        recyclerView.setAdapter(adapter);

        recyclerView.setLayoutManager(manager);


    }

}